package it.tcm.TeacherClassMate.util;

import it.tcm.TeacherClassMate.beans.TransactionBean;
import java.text.DecimalFormat;
import java.util.Date;
import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.TableDecorator;

public class UserdataWrapper  extends TableDecorator {
	
  /**
  * FastDateFormat used to format dates in getDate().
  */
 private FastDateFormat dateFormat;
 private FastDateFormat dateOraFormat;

 /**
  * DecimalFormat used to format money in getMoney().
  */
 private DecimalFormat moneyFormat;

 /**
  * Creates a new Wrapper decorator who's job is to reformat some of the data located in our TestObject's.
  */
 public UserdataWrapper()
 {
     super();

     // Formats for displaying dates and money.

     this.dateFormat = FastDateFormat.getInstance("dd/MM/yyyy"); //$NON-NLS-1$
     this.moneyFormat = new DecimalFormat("$ #,###,###.00"); //$NON-NLS-1$
     this.dateOraFormat = FastDateFormat.getInstance("dd/MM/yyyy hh:mm:ss a"); //$NON-NLS-1$
 }

 /**
  * Test method which always returns a null value.
  * @return <code>null</code>
  */
 public String getNullValue()
 {
     return null;
 }

 
 public String getBuydate() 
 {   	  	
 	Date data = ((TransactionBean) this.getCurrentRowObject()).getBuydate();
 	if (data != null)  {
 		return this.dateFormat.format(data);
 	} else {
 		return "";
 	}	
 }


}
